package erfgame.frontend.desktop.view.terrain.iso.interaction.position;

import erfgame.core.Point3D;
import erfgame.core.Rectangle3D;
import erfgame.core.world.World;
import erfgame.core.world.terrain.TerrainUpdateGroup;

import erfgame.frontend.desktop.view.terrain.iso.interaction.TerrainUpdatePositionFactory;

public class CenterTerrainUpdatePositionFactory implements
		TerrainUpdatePositionFactory {

	public Point3D getPosition(Point3D anchor, TerrainUpdateGroup terrainUpdate,
			World world) {
		Rectangle3D bounds = terrainUpdate.getBounds();
		return new Point3D( 
				anchor.x - bounds.minX - bounds.getWidth()/2,
				anchor.y - bounds.minY - bounds.getHeight()/2,
				anchor.z - bounds.minZ - bounds.getDepth()/2
		);
	}

}
